<?php
ob_start(); // 开启输出缓冲
// 先输出 HTML 或其他内容
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
		<title>图片</title>
		<style>
			html,body{
				height: 100%;
				width: 100%;
				padding: 0px;
				margin: 0px;
			}
			#zhuangtailanziti{
				margin: 0px;
				padding: 15px 30px 10px 0px;
				font-size: 15px;
				font-weight:bold;
				font-family: 微软雅黑;
				color: #000;
			}
			#zhuangtailanziti:hover{
				margin: 0px;
				padding: 15px 30px 10px 0px;
				font-size: 15px;
				font-weight:bold;
				font-family: 微软雅黑;
				color:#1E90FF;
			}
			.no-scrollbar {  
				scrollbar-width: none; /* Firefox */  
			    -ms-overflow-style: none; /* IE and Edge */  
			}
			::-webkit-scrollbar {
			display: none; /* Chrome, Safari and Opera */  
			}   
		</style>
	</head>
	<body class="no-scrollbar">
		<center>
		<div class="no-scrollbar" style="width: 100%;display: flex;">
			<div class="no-scrollbar" style="width: 900px;text-align:left;">
			<!--读取文件-->
			<?php
				header("Content-Type:text/html; charset=utf-8");
				$dir = "./file/";
				//打开一个目录，然后读取其内容
				if (is_dir($dir)){//检测是否是一个目录
				  if ($dh = opendir($dir)){//判断打开目录是否成功
					while (($file = readdir($dh)) !== false)//循环返回目录中下一个文件的文件名
					{    
						//计算文件大小
						$wenjiansize ="./file/".$file;
						$wenjiansize = filesize($wenjiansize);
						$wenjiansize = $wenjiansize/1024;
						$wenjiansize = $wenjiansize." KB";
						//获取文件更改时间
						$filetime ="./file/".$file;
						$filetime = filemtime($filetime);
						$filetime=date("Y-m-d H:i:s",$filetime);
						if($file !="." and $file !=".."){//删除..和.目录
						echo
						"<a style='text-decoration:none;' target=_top  href='./file/".$file."'>".
						"<div style='display: flex;box-shadow: 0px 0px 3px #888888;border-radius: 10px;padding:5px 5px 10px 5px;margin:10px 10px 0px 10px;'>".
							"<div style='width: auto;'>".
								"<p id='zhuangtailanziti' style='font-size:15px;margin: 0px;padding: 10px 0px 0px 10px;font-weight:bold;font-family:微软雅黑;'>".$file."</p>".
								"<p style='font-size:10px;margin: 0px;color:#808080;padding: 0px 0px 0px 10px;font-weight:bold;'>".$wenjiansize."</p>".
							"</div>".
							"<div style='width: auto;'>".
								"<p style='font-size:13px;margin: 0px;color:#696969;padding: 15px 0px 0px 10px;'>".$filetime."</p>".
							"</div>".
						"</div>".
						"<a/>";
						}
					}
				  }
				  else {
					  echo "路径错误";
					  exit();
				  }
					  closedir($dh);//关闭目录
				}
			?>
			</div>
		</div>
		</center>
	</body>
</html>
